﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using UtilityExtensions;
using BOL;
using BOL.Ventas;
using DAL;
using System.Data.SqlClient;
using Website.Logger;

namespace UILGestion.ObraAdmin.OrdenCompras
{
    public partial class OrdenCompraList2Grid : System.Web.UI.UserControl
    {


        public OrdenCompraList2Grid()
        {
            bol = new BOL.OrdenCompraBL();
            _db = new dbGestionDataContext(DbUtil.strConnString);
        }
        private BOL.OrdenCompraBL bol;
        private dbGestionDataContext _db;



        public event EventHandler DataBound;

        public int pagesize { get { return Util.GetPageSizeCookie(); } }
        protected void Page_Load(object sender, EventArgs e)
        {
            pager.PageSize = pagesize;

        }

        public override void DataBind()
        {
        ListView1.DataBind();
        }
        public string DataSourceID
        {
            set { ListView1.DataSourceID = value; }
        }
        public object DataSource
        {
            set { ListView1.DataSource = value; }
        }

        protected void ListView1_DataBound(object sender, EventArgs e)
        {
            if (DataBound != null)
                DataBound(sender, e);
        }
        public DataPager DataPager
        {
            get { return pager; }
        }
        public int TopRolId
        {
            get { return (int)ListView1.DataKeys[0].Value; }
        }

        protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                var link = e.Item.FindControl("HyperLink1") as HyperLink;
                var r = e.Item as ListViewDataItem;
                var d = r.DataItem as OrdenCompraListInfo;
                //link.NavigateUrl ="javascript:PageMethods.ToggleTag({0},'{1}',ToggleTagCallback)".Fmt(d.idInternal, link.ClientID);

              
            }
        }
        //protected void Deleteitem(object sender, EventArgs e)
        //{
        //    try
        //    {

        //        ImageButton lnkRemove = (ImageButton)sender;
        //        bol.DeleteOrdenVenta(lnkRemove.CommandArgument.ToInt());
        //        this.DataBind();

        //    }
        //    catch (SqlException sqlex)
        //    {
        //        WebServerSideSqlError.Log(sqlex);
        //        ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
        //         "uniqueKey" + DateTime.Now, "alert('"+sqlex.Message.Replace("'","").Replace("\r","").Replace("\n","")+"');", true);


        //    }
        //    catch (Exception ex)
        //    {
        //        WebServerSideError.Log(ex);
        //        ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
        //         "uniqueKey" + DateTime.Now, "alert('" + ex.Message.Replace("'", "") + "');", true);

        //    }
        //}

        //protected void opcionBTN(object sender, EventArgs e)
        //{
        //    try
        //    {

        //        Button lnk = (Button)sender;
                 
               
               
        //        this.DataBind();

        //    }
        //    catch (SqlException sqlex)
        //    {
        //        WebServerSideSqlError.Log(sqlex);
        //        ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
        //         "uniqueKey" + DateTime.Now, "alert('"+sqlex.Message.Replace("'","").Replace("\r","").Replace("\n","")+"');", true);


        //    }
        //    catch (Exception ex)
        //    {
        //        WebServerSideError.Log(ex);
        //        ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
        //         "uniqueKey" + DateTime.Now, "alert('" + ex.Message.Replace("'", "") + "');", true);

        //    }
        //}
        

        
    }
}